With GnuPG 2, any time you do basically any operation, a gpg-agent will
be spawned for the GPG home directory in use. The classic way to kill a
gpg-agent is to use `gpg-connect-agent` and send the `killagent` command
as is done in libtest.sh.
Closes: #1799
Approved by: cgwalters
return g_steal_pointer (&context);
}
+
+void
+ot_gpgme_kill_agent (const char *homedir)
+{
+ g_return_if_fail (homedir != NULL);
+
+ /* Run gpg-connect-agent killagent /bye */
+ g_autoptr(GError) local_error = NULL;
+ g_autoptr(GSubprocess) proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_SILENCE,
+ &local_error,
+ "gpg-connect-agent",
+ "--homedir",
+ homedir,
+ "killagent",
+ "/bye",
+ NULL);
+ if (proc == NULL) {
+ g_debug ("Spawning gpg-connect-agent failed: %s", local_error->message);
+ return;
+ }
+ if (!g_subprocess_wait_check (proc, NULL, &local_error)) {
+ g_debug ("Killing GPG agent with gpg-connect-agent failed: %s",
+ local_error->message);
+ return;
+ }
+}
gpgme_ctx_t ot_gpgme_new_ctx (const char *homedir,
GError **error);
+void ot_gpgme_kill_agent (const char *homedir);
+
G_END_DECLS